//
//  triple.cpp
//  cobalt
//
//  Created by Nicolas Godbout on 2013-08-28.
//  Copyright (c) 2013 Nicolas Godbout. All rights reserved.
//

#include "triple.h"

namespace rdf {
    bool
    Triple::lessSPO::operator() (Triple const& lhs, Triple const& rhs) const noexcept
    {
        if ( lhs.subject().node < rhs.subject().node )
            return true;
        else if ( lhs.subject().node == rhs.subject().node ) {
            if ( lhs.predicate().node < rhs.predicate().node )
                return true;
            else if ( lhs.predicate().node == rhs.predicate().node )
                return lhs.object().node < rhs.object().node;
            else
                return false;
        } else
            return false;
    }
                bool
                Triple::lessST::operator() (Triple const& lhs, Triple const& rhs) const noexcept {
                    if ( lhs.subject().node < rhs.subject().node )
                        return true;
                    else if ( lhs.isPattern() || rhs.isPattern() )
                        return false;
                    else if ( lhs.subject().node == rhs.subject().node )
                        return lhs.triple < rhs.triple;
                    else
                        return false;
                }
                bool
                Triple::lessPT::operator() (Triple const& lhs, Triple const& rhs) const noexcept {
                    if ( lhs.predicate().node < rhs.predicate().node )
                        return true;
                    else if ( lhs.isPattern() || rhs.isPattern() )
                        return false;
                    else if ( lhs.predicate().node == rhs.predicate().node )
                        return lhs.triple < rhs.triple;
                    else
                        return false;
                }
                bool
                Triple::lessOT::operator() (Triple const& lhs, Triple const& rhs) const noexcept {
                    if ( lhs.object().node < rhs.object().node )
                        return true;
                    else if ( lhs.isPattern() || rhs.isPattern() )
                        return false;
                    else if ( lhs.object().node == rhs.object().node )
                        return lhs.triple < rhs.triple;
                    else
                        return false;
                }
}